package com.zhhs.jzcd.account.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.checkerframework.checker.units.qual.A;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhhs.framework.aspectj.lang.annotation.Log;
import com.zhhs.framework.aspectj.lang.enums.BusinessType;
import com.zhhs.jzcd.account.domain.BaseJournalAccount;
import com.zhhs.jzcd.account.service.IBaseJournalAccountService;
import com.zhhs.framework.web.controller.BaseController;
import com.zhhs.framework.web.domain.AjaxResult;
import com.zhhs.common.utils.poi.ExcelUtil;
import com.zhhs.framework.web.page.TableDataInfo;

/**
 * 企业账户流水Controller
 *
 * @author ruoyi
 * @date 2023-08-04
 */
@RestController
@RequestMapping("/jzcd/account")
public class BaseJournalAccountController extends BaseController
{
    @Autowired
    private IBaseJournalAccountService baseJournalAccountService;

    /**
     * 查询企业账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('account:account:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseJournalAccount baseJournalAccount)
    {
        startPage();
        List<BaseJournalAccount> list = baseJournalAccountService.selectBaseJournalAccountList(baseJournalAccount);
        return getDataTable(list);
    }

    /**
     * 导出企业账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('account:account:export')")
    @Log(title = "企业账户流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseJournalAccount baseJournalAccount)
    {
        List<BaseJournalAccount> list = baseJournalAccountService.selectBaseJournalAccountList(baseJournalAccount);
        ExcelUtil<BaseJournalAccount> util = new ExcelUtil<BaseJournalAccount>(BaseJournalAccount.class);
        util.exportExcel(response, list, "企业账户流水数据");
    }

    /**
     * 获取企业账户流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('account:account:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(baseJournalAccountService.selectBaseJournalAccountById(id));
    }

    /**
     * 新增企业账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:account:add')")
    @Log(title = "企业账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseJournalAccount baseJournalAccount)
    {
        return toAjax(baseJournalAccountService.insertBaseJournalAccount(baseJournalAccount));
    }

    /**
     * 修改企业账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:account:edit')")
    @Log(title = "企业账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseJournalAccount baseJournalAccount)
    {
        return toAjax(baseJournalAccountService.updateBaseJournalAccount(baseJournalAccount));
    }

    /**
     * 删除企业账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:account:remove')")
    @Log(title = "企业账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(baseJournalAccountService.deleteBaseJournalAccountByIds(ids));
    }

    /**
     * 账户流水金额统计
     */
    @GetMapping("/getAmountDetails")
    public AjaxResult getAmountDetails(){
        return AjaxResult.success(baseJournalAccountService.selectAmountDetails());
    }

    /**
     * 企业名称下拉框
     */
    @GetMapping("/getBusinessName")
    public AjaxResult getBusinessName(){
        return AjaxResult.success(baseJournalAccountService.selectBusinessName());
    }

}
